﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RM2012Service.DataAccess;
using System.Data;
using RM2012Service.Business;

namespace RM2012Service.Controller
{
    public class InvoiceCtrl
    {
        InvoiceDAO dao;

        public InvoiceCtrl()
        {
            dao = new InvoiceDAO();
        }

        public DataSet GetAllInvoice()
        {
            return dao.GetAllInvoice();
        }

        public DataSet GetAllInvoicePaid()
        {
            return dao.GetAllInvoicePaid();
        }

        public DataSet GetAllInvoiceNotPaid()
        {
            return dao.GetAllInvoiceNotPaid();
        }

        public DataSet GetAllInvoiceById(String invoiceId)
        {
            return dao.GetAllInvoiceById(invoiceId);
        }

        public bool Add(InvoiceInfo info)
        {
            if (dao.Add(info) > 0)
            {
                return true;
            } 
            else
            {
                return false;
            }
        }

        public bool Update(InvoiceInfo info)
        {
            if (dao.Update(info) > 0)
            {
                return true;
            } 
            else
            {
                return false;
            }
        }

        public bool UpdateTotal(InvoiceInfo info)
        {
            if (dao.UpdateTotal(info) > 0)
            {
                return true;
            } 
            else
            {
                return false;
            }
        }

        public bool UpdatePaid(InvoiceInfo info)
        {
            if (dao.UpdatePaid(info) > 0)
            {
                return true;
            } 
            else
            {
                return false;
            }
        }

        public bool UpdateNeeded(InvoiceInfo info)
        {
            if (dao.UpdateNeeded(info) > 0)
            {
                return true;
            } 
            else
            {
                return false;
            }
        }

        public bool Delete(String invoiceId)
        {
            if (dao.Delete(invoiceId) > 0)
            {
                return true;
            } 
            else
            {
                return false;
            }
        }
    }
}
